import React, { Component } from 'react'
import ThemeContext from './context/theme-context'
import UserContext from './context/user-context';
import NavBar from './NavBar';
export class ProductInfo extends Component {
  render() {
    // 4.类组件从 this.context中拿到数据 / 也可从 xxx.Consumer 中取到
    console.log(this.context);
    return (
      <div>
        ProductInfo: themeColor: {this.context.color}
        <UserContext.Consumer>
          {
            value => <div>nikename:<i>{ value.nikename}</i></div>
          }
        </UserContext.Consumer>
        <NavBar/>
      </div>
    )
  }
}
// 3.给需要接收跨父子的组件的 contextType 设置为需要接收的context名称
ProductInfo.contextType = ThemeContext
export default ProductInfo